package org.devknights.android.andlib.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class PatternUtil {
	Pattern pttr = null;
	Matcher matcher = null;

	public PatternUtil(String ptr, boolean caseSensitive) {
		if (caseSensitive) {
			pttr = Pattern.compile(ptr, Pattern.CASE_INSENSITIVE);
		} else {
			pttr = Pattern.compile(ptr);
		}
	}

	public boolean groupsFound(String str) {
		matcher = pttr.matcher(str);
		return matcher.find();
	}

	public boolean matches(String str) {
		matcher = pttr.matcher(str);
		return matcher.matches();
	}

	public int getGroupCount() {
		return matcher.groupCount();
	}

	public String getGroup(int g) {
		return matcher.group(g);
	}

	
	public boolean found() {
		return matcher.find();
	}

	public void find(String ln) {
		matcher = pttr.matcher(ln);
	}

	public String getMatch() {
		return matcher.group();
	}

}
